<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的详情页</title>
    <script src="jquery-1.9.1.min.js"></script>
    <script>
        // 时间格式化
        function datefm(timespan) {
            var date = new Date(timespan);
            // 获得年份
            var year = date.getFullYear();
            // 获得月份【注意+1】
            var months = date.getMonth() + 1;
            // 获得日期
            var date1 = date.getDate();
            return year + "-" + months + "-" + date1;
        }

        jQuery(function () {
            // 1.文章id从url中获取
            var id = location.search.split("=")[1];
            jQuery.getJSON("initart", {"id": id}, function (data) {
                if (data != null && data.state == 1) {
                    // 得到文章对象
                    var art = data.art;
                    jQuery("#title").html(art.title);
                    jQuery("#content").html(art.content);
                    jQuery("#createtime").html(datefm(art.createtime));
                    jQuery("#username").html(art.username);
                    jQuery("#rcount").html(art.rcount);
                } else {
                    alert("查询失败" + data.msg);
                }
            });
            // 2.执行访问量+1
            jQuery.getJSON("upcount", {"id": id}, function (data) {
            });
        });
    </script>
</head>
<body>
<div style="margin-top: 30px;margin-left: 70px;">
    <h2 id="title">标题：</h2>
    <div style="text-align: left">
        <strong>发布时间：</strong><span id="createtime"></span>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <strong>作者：</strong><span id="username"></span>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <strong>阅读量：</strong><span id="rcount"></span>
    </div>
    <hr>
    正文：
    <div id="content"></div>
</div>
</body>
</html>